package com.hebang.stcommunityapp.activitys;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.hebang.stcommunityapp.R;
import com.hebang.stcommunityapp.adapters.DeviceListdapter;
import com.hebang.stcommunityapp.beans.SyItemBean;
import com.hebang.stcommunityapp.databinding.ActivityDeviceDetBinding;

import java.util.ArrayList;

public class DeviceDetActivity extends AppCompatActivity {
ActivityDeviceDetBinding binding;
    DeviceListdapter adapter;
    RecyclerView recyclerview;
    private ArrayList<SyItemBean> list = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide();
        binding= DataBindingUtil.setContentView(this, R.layout.activity_device_det);
        initdata();
        initRecycler();
    }


    private void initRecycler(){
        if (adapter == null) {
            recyclerview = binding.statutefragmentRecyclerview;
            GridLayoutManager layoutManager = new GridLayoutManager(DeviceDetActivity.this, 1);
            recyclerview.setLayoutManager(layoutManager);
            adapter = new DeviceListdapter(list);
            recyclerview.setAdapter(adapter);
            adapter.setOnItemClickListener(new DeviceListdapter.OnItemClickListener() {
                @Override
                public void onClick(View view, int position) {
//                    Intent intent=new Intent(DeviceDetActivity.this, DeviceDetActivity.class);
//                    startActivity(intent);

                }
            });
        } else {
            adapter.notifyDataSetChanged();
        }
    }


    private void initdata(){
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());

    }
}